<ul class="basictab">
<li class="selected"><a href="/index/funeraldirector/funeraldir_id/<?php echo $this->FDMS_license_number?>">Profile</a></li>
<li><a href="/index/funeraldirectormodules/funeraldir_id/<?php echo $this->FDMS_license_number?>">Module Order</a></li>
</ul>
<div class="basictabdiv">
<?php

	// also do the reporting stats in here...
	
	$qs = $this->quick_stats;
	$str1 = sprintf("TOTAL Number of cases: %d", $qs['num_cases']);
	$str2 = sprintf("Average time per case: %.1f seconds", $qs['time_per_case']);
	$overall = "<div>$str1<br>$str2</div>";
	
	$per_module = "Average time per module:";
	foreach($qs['module_times'] as $module_name=>$tuple)
	{
		$per_module .= "<div>";
		$per_module .= sprintf("%s: %.1f seconds", $module_name, $tuple['Average']);
		$per_module .= "</div>";
	}
	
	$quick_stats = "$overall $per_module";
	
	// $this->bstats and $this->brevs
	$arranger_timing_stats = sprintf("<br>Total Cases: %d<br>Shortest Time: %.1f<br>Longest Time: %.1f<br>Average Time: %.1f", 
		$this->astats['num_cases'], $this->astats['min_casetime'], $this->astats['max_casetime'], $this->astats['avg_casetime'] );
		
	$arranger_revenue_stats = sprintf("<br>Total Cases: %d<br>Lowest Revenue: \$%.02f<br>Highest Revenue: \$%.02f<br>Total Revenue: \$%.02f<br>Average Revenue: \$%.02f", 
		$this->arevs['num_cases'], 
		$this->arevs['min_revenue'], 
		$this->arevs['max_revenue'], 
		$this->arevs['sum_revenue'], 
		$this->arevs['avg_revenue'] );
		
	$branch_timing_stats = sprintf("<br>Total Cases: %d<br>Shortest Time: %.1f<br>Longest Time: %.1f<br>Average Time: %.1f", 
		$this->bstats['num_cases'], $this->bstats['min_casetime'], $this->bstats['max_casetime'], $this->bstats['avg_casetime'] );
	$branch_revenue_stats = sprintf("<br>Total Cases: %d<br>Lowest Revenue: \$%.02f<br>Highest Revenue: \$%.02f<br>Total Revenue: \$%.02f<br>Average Revenue: \$%.02f", 
		$this->brevs['num_cases'], 
		$this->brevs['min_revenue'], 
		$this->brevs['max_revenue'], 
		$this->brevs['sum_revenue'], 
		$this->brevs['avg_revenue'] );
		
	$region_timing_stats = sprintf("<br>Total Cases: %d<br>Shortest Time: %.1f<br>Longest Time: %.1f<br>Average Time: %.1f", 
		$this->rstats['num_cases'], $this->rstats['min_casetime'], $this->rstats['max_casetime'], $this->rstats['avg_casetime'] );
	$region_revenue_stats = sprintf("<br>Total Cases: %d<br>Lowest Revenue: \$%.02f<br>Highest Revenue: \$%.02f<br>Total Revenue: \$%.02f<br>Average Revenue: \$%.02f", 
		$this->rrevs['num_cases'], 
		$this->rrevs['min_revenue'], 
		$this->rrevs['max_revenue'], 
		$this->rrevs['sum_revenue'], 
		$this->rrevs['avg_revenue'] );

	$keystone_timing_stats = sprintf("<br>Total Cases: %d<br>Shortest Time: %.1f<br>Longest Time: %.1f<br>Average Time: %.1f", 
		$this->cstats['num_cases'], $this->cstats['min_casetime'], $this->cstats['max_casetime'], $this->cstats['avg_casetime'] );
	$keystone_revenue_stats = sprintf("<br>Total Cases: %d<br>Lowest Revenue: \$%.02f<br>Highest Revenue: \$%.02f<br>Total Revenue: \$%.02f<br>Average Revenue: \$%.02f", 
		$this->crevs['num_cases'], 
		$this->crevs['min_revenue'], 
		$this->crevs['max_revenue'], 
		$this->crevs['sum_revenue'], 
		$this->crevs['avg_revenue'] );
		
    $options = array();
    $options['picture_path'] = "/art/FD/".$this->funeral_dir_profile['photo'];
    $options['can_edit_username'] = 'true';
    $options['funeral_dir_profile'] = $this->funeral_dir_profile;
    $options['selected_branch'] = $this->branch_number;
    $options['action'] = $this->url( array('controller'=>'index', 'action'=>'funeraldirector') );
    $options['quick_stats'] = $quick_stats;
    
	$options['arranger_timing'] = $arranger_timing_stats;
 	$options['arranger_revenue'] = $arranger_revenue_stats;
	$options['branch_timing'] = $branch_timing_stats;
 	$options['branch_revenue'] = $branch_revenue_stats;
	$options['region_timing'] = $region_timing_stats;
	$options['region_revenue'] = $region_revenue_stats;
	$options['keystone_timing'] = $keystone_timing_stats;
	$options['keystone_revenue'] = $keystone_revenue_stats;
    
    $form = new FuneralDirectorForm( $options );

    // run a validity check here.
    $is_valid = $form->isValid( $this->funeral_dir_profile );

    // populate the form with the profile data
    $form->populate( $this->funeral_dir_profile );

    // now that we've got the form populated (and optionally have error messages)
    $form->render_with_template( "funeraldirectorprofile.xhtml" );    
 ?>
 </div>
 